package com.ces.knacky.controller.tools;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

import com.ces.knacky.framework.controller.BaseController;

/**
 * Creates a new bid and persists it.
 * 
 * @author shivangi_walvekar
 * 
 */
// TODO - remove sysouts
@Controller
public class CreateBidController extends BaseController {

	/**
	 * Comma separated list of Item ids selected from the JSP page.
	 */
	private String selectedId;

	/**
	 * 
	 * @return selectedIds
	 */
	public String getSelectedId() {
		return selectedId;
	}

	/**
	 * 
	 * @param selectedIds
	 */
	@ModelAttribute("selectedId")
	public void setSelectedIds(String selectedId) {
		this.selectedId = selectedId;
	}
	
	private String selectedAuction;

	/**
	 * 
	 * @return auctionDescription
	 */

	public String getSelectedAuction() {
		return selectedAuction;
	}

	/**
	 * 
	 * @param auctionDescription
	 */
	@ModelAttribute("selectedAuction")
	public void setSelectedAuction(String selectedAuction) {
		this.selectedAuction = selectedAuction;
	}


	@RequestMapping("/createBid.htm")
	public String execute(HttpServletRequest request) {
		System.out.println("CreateBidController () : selectedAuction = "+ getSelectedAuction());
		HttpSession session = request.getSession(true);		
		session.setAttribute("itemId", getSelectedId());
//		Integer auctionID =  (Integer) session.getAttribute("selectedAuctionId");
//		System.out.println("#$#$### selected auction id from session = "+auctionID);
//		session.setAttribute("selectedAuctionId", getSelectedAuction());	
		return "createBid";
	}
}
